package com.dianxin.smartpark.web.park;

import java.util.List;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.chinatelecom.response.common.CommonResponseBody;
import com.dianxin.smartpark.dao.qo.park.SmartParkCarQO;
import com.dianxin.smartpark.service.park.SmartParkCarService;
import com.dianxin.smartpark.service.vo.common.SmartParkUserCardVO;
import com.dianxin.smartpark.service.vo.park.DevicePullDataCarVo;
import com.dianxin.smartpark.service.vo.park.SmartParkCarVO;
import com.dianxin.smartpark.service.vo.park.SmartParkUserCarVO;
import com.dianxin.sso.client.annotation.RecordLog;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 车辆管理
 * 
 * @author chenjiasong
 * @date 2021-07-28
 */
@RestController
@RequestMapping("/smartpark/car")
public class SmartParkCarController
{
    @Resource
    private SmartParkCarService smartParkCarService;

    /**
     * 查询车辆管理列表
     */
    @GetMapping("/list")
    @SaCheckPermission(value = "/smartpark/car/list")
    public CommonResponseBody<List<SmartParkCarVO>>  list(SmartParkCarQO qo)
    {
        return smartParkCarService.selectSmartParkCarList(qo);
    }


    /**
     * 获取车辆管理详细信息
     */
    @GetMapping(value = "/getInfo")
    @SaCheckPermission(value = "/smartpark/car/getInfo")
    public CommonResponseBody<SmartParkCarVO> getInfo(SmartParkCarQO qo)
    {
        return smartParkCarService.selectSmartParkCar(qo);
    }

    /**
     * 查询用户card信息
     */
    @PostMapping("/getUserCarDetailList")
    public CommonResponseBody<List<SmartParkUserCarVO>>  selectUserCarDetailList(@RequestBody DevicePullDataCarVo devicePullDataCarVo) throws Exception {
        return smartParkCarService.selectSmartParkUserCarList(devicePullDataCarVo);
    }

    /**
     * card查询设备用户信息
     */
    @PostMapping("/getUserCarDetailListByCar")
    public CommonResponseBody<SmartParkUserCarVO>  selectUserCarDetailListByCar(@RequestBody DevicePullDataCarVo devicePullDataCarVo) throws Exception {
        return smartParkCarService.selectSmartParkUserCarListByCar(devicePullDataCarVo);
    }

    /**
     * 新增车辆管理
     */
    @PostMapping("/add")
    @SaCheckPermission(value = "/smartpark/car/add")
    @RecordLog(name = "新增车牌")
    public  CommonResponseBody<Boolean> add(@RequestBody SmartParkCarVO vo) throws Exception {
        return smartParkCarService.insertSmartParkCar(vo);
    }

    /**
     * 修改车辆管理
     */
    @PutMapping("/edit")
    @SaCheckPermission(value = "/smartpark/car/edit")
    public  CommonResponseBody<Boolean> edit(@RequestBody SmartParkCarVO vo)
    {
        return smartParkCarService.updateSmartParkCar(vo);
    }

    /**
     * 删除车辆管理
     */
	@DeleteMapping("/remove")
    @SaCheckPermission(value = "/smartpark/car/remove")
    @RecordLog(name = "删除车牌")
    public  CommonResponseBody<Boolean> remove(@RequestBody SmartParkCarVO vo) throws Exception {
        return smartParkCarService.deleteSmartParkCar(vo);
    }
}
